<?php

namespace App\Http\Middleware;

use Closure;

class TestMiddleware
{
    /**
     * Handle an incoming request.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle($request, Closure $next)
    {
        //获取请求的路由
        // $path = $request -> path();
        $str = '['.date('Y-m-d H:i:s').']'.$request->ip().'-----'.$request->path();
        //将字符串存入文件中
        file_put_contents('request.log', $str."\r\n", FILE_APPEND);
        //进入下一层的代码
        return $next($request);
    }
}
